#include "flash_api.h"
#include "flash_board.h"

void DeleteAllTemporaryFile(void)
{
  FlashDeleteTemporaryFile();
}

void ReadTheTemporaryFile(uint32_t ReadAddress, uint8_t *pDataOut, uint16_t SizeOut)
{
  // TemporaryFileFormat_t TemporaryFileFormat = {0};

  // if ((pDataOut != NULL) && (SizeOut > 0))
  // {
  //   FlashReadTemporaryFile(0, &TemporaryFileFormat, sizeof(TemporaryFileFormat_t));
  //   if ((ReadAddress + SizeOut) <= TemporaryFileFormat.FileSize)
  //   {
  //     memcpy(pDataOut, &TemporaryFileFormat.DataPacket[ReadAddress], SizeOut);
  //   }
  // }
}

bool WriteToTemporaryFile(uint32_t WriteAddress, const uint8_t *pDataIn, uint16_t SizeIn)
{
  // TemporaryFileFormat_t TemporaryFileFormat = {0};

  // if ((pDataIn != NULL) && (SizeIn > 0))
  // {
  //   FlashReadTemporaryFile(0, &TemporaryFileFormat, sizeof(TemporaryFileFormat_t));
  //   if ((WriteAddress + SizeIn) <= TemporaryFileFormat.FileSize)
  //   {
  //     memcpy(&TemporaryFileFormat.DataPacket[WriteAddress], pDataIn, SizeIn);
  //     return FlashWriteTemporaryFile(0, &TemporaryFileFormat, sizeof(TemporaryFileFormat_t));
  //   }
  // }

  return false;
}

uint8_t CalculateTemporaryFileCheckCode(uint32_t FilzeSize)
{
  // return FlashCalculateFileAccumulateCleckCode(FLASH_START_ADDR_TEMPORARY_FILE_SECTOR , FilzeSize);
}